/*
 * ExtractorDePaths.cpp
 *
 *  Created on: Aug 30, 2011
 *      Author: damian
 */
#include "ExtractorDePaths.h"
#include <iostream>
#include "string.h"
using namespace std;


ExtractorDePaths::ExtractorDePaths() {
}

ExtractorDePaths::~ExtractorDePaths() {
}

list<string>* ExtractorDePaths::verArchivos(string path) {
	list<string>* paths = new list<string>();
	this->verArchivosRecursivo(path, paths);
	return paths;
}

void ExtractorDePaths::verArchivosRecursivo(string path, list<string>* paths) {
	DIR* dir = NULL;
	struct dirent* entry;

	if ((dir = opendir(path.c_str())) == NULL) {
		return;
	}

	while((entry = readdir(dir)) != NULL) {
		char *name = entry->d_name;
		string sName = string(name);

		if(sName != "." && sName != "..") {
			if (entry->d_type == DT_DIR) {
				this->verArchivosRecursivo(path + "/" + sName, paths);
			} else {
				paths->push_back(path + "/" + sName);
			}
		}
	}
	return;
}
